home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.mactech.com 2010
/
ftp.mactech.com.tar
/
ftp.mactech.com
/
machack
/
Hacks97
/
WarriorsProgress.sit
/
Warrior’s Progress
/
source code
/
Source
/
Libraries
/
Heap
/
HeapLink.cp
< prev
next >
Wrap
Text File
|
1997-06-28
|
966b
|
58 lines
// HeapLink.cp
#ifndef HeapLink_h
#include "HeapLink.h"
#endif
#ifndef Heap_h
#include "Heap.h"
#endif
#ifndef Swap_h
#include "Swap.h"
#endif
#ifndef Heap_h
#include "Heap.h"
#endif
template < class Element >
HeapLink<Element>::HeapLink( Element *e )
: heap( 0 ),
body( e ),
path( 0 )
{
children[0] = 0;
children[1] = 0;
}
template < class Element >
HeapLink<Element>::~HeapLink()
{
if ( heap != 0 )
heap->Remove( *this );
Assert( heap == 0 );
}
template < class Element >
void HeapLink<Element>::SwapWith( LinkType& r )
{
Assert( heap == r.heap );
Swap( path, r.path );
Swap( children[0], r.children[0] );
Swap( children[1], r.children[1] );
}
template < class Element >
bool HeapLink<Element>::operator<=( const LinkType& r ) const
{
Assert( heap == r.heap );
Assert( heap != 0 );
Comparator below( heap->Below() );
Assert( below != 0 );
Assert( !Null() );
Assert( !r.Null() );
return (body->*below)(*r.body);
}